﻿using UnityEngine;
using System.Collections;
using System.Net;

public class DownLoader {

	public delegate void Event();

	public Event DownLoadEnd;

	void DownloadFile(string downLoadUrl)
	{
	    WebClient client = new WebClient();
	    client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler( DownloadFileCompleted );
	    client.DownloadFileAsync (
			new System.Uri (downLoadUrl),Application.persistentDataPath + "/" + "moviefile.mp4"
	    );
	}

	void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
	{
	    if (e.Error == null)
	    {
			DownLoadEnd ();
	    }
	}
}
